<?php

$username = $_POST['username'];
$password = $_POST['password'];

include("opendb.php");
include("functions.php");
$res = isValidUser($username,$password);
if($res!=1) {
echo "$username = $password";
exit;
}

$listingid = $_POST['listingid'];
$query = "select * from Users where Username='".$username."'";
$result = mysql_query($query) or die ("SQL Error".mysql_error());
$row=mysql_fetch_assoc($result);
$userid = $row['ID'];



		$lquery = "select * from PROPERTIES p inner join Prop_Owner_Con c on p.OID = c.Prop_OID where p.OID='".$listingid."' and c.Owner = '".$userid."'";
		$lresult = mysql_query($lquery) or die ("SQL Error".mysql_error());
		$listing_row=mysql_fetch_assoc($lresult);
		if (mysql_num_rows($lresult) === 0)
		{
			echo "101";
			exit;
		}

if(isset($_POST['areaname']) && $_POST['listingid'] != "")
{
	$query = "Insert into Listing_Areas(Owner, Listing_ID, Name, Date_Created)Values('".getOID($username)."','".$_POST['listingid']."','".$_POST['areaname']."','".date('Y-m-d H:i:s')."')";
	//echo $query;
	mysql_query($query) or die(mysql_error()); 
}

echo "1";



?>